package com.niit.schoolhub.system.utils;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.UUID;


public class JwtUtils {
    private long time=1000*60*60*24;
    private String signature="admin";
    public void jwt(){
        JwtBuilder builder = Jwts.builder();
        String jwtToken=builder
                .setHeaderParam("typ","JWT")
                .setHeaderParam("alg","HS256")
                //payload
                .claim("last_login_time", LocalDateTime.now().toString())
                .claim("last_login_ip",LocalDateTime.now().toString())
                .setSubject("admin-test")
                .setExpiration(new Date(System.currentTimeMillis()+time))
                .setId(UUID.randomUUID().toString())
                .signWith(SignatureAlgorithm.HS256,signature)
                .compact();
        System.out.println(jwtToken);
    }
}
